﻿Imports MvcMusicStoreVB.Models

Namespace Controllers
    Public Class StoreController
        Inherits System.Web.Mvc.Controller

        Private storeDb As MusicStoreEntities = New MusicStoreEntities

        '
        ' GET: /Store
        Function Index() As ActionResult
            Dim genres = storeDb.Genres.ToList
            Return View(genres)
        End Function

        '
        ' GET: /Store/Browse?genre=Disco
        Function Browse(ByVal genre As String) As ActionResult
            Dim genreModel = storeDb.Genres.Include("Albums").Single(Function(g) g.Name = genre)
            Return View(genreModel)
        End Function

        '
        ' GET: /Store/Details/5
        Function Details(ByVal id As Integer) As ActionResult
            Dim album = storeDb.Albums.Find(id)
            Return View(album)
        End Function

        '
        ' GET: /Store/GenreMenu
        <ChildActionOnly()>
        Function GenreMenu() As ActionResult
            Dim genres = storeDb.Genres.ToList
            Return PartialView(genres)
        End Function

    End Class
End Namespace